home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / compress / dmpexe22.zip / DUMPEXE.TXT < prev    next >
Text File  |  1997-02-26  |  34KB  |  665 lines

  1.  ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  2.  █                                                                            █
  3.  █                     <*>   EXE-dumper version 2.2   <*>                     █
  4.  █                                                                            █
  5.  █                  by ▄─▄ ▄   ▄─▄ ▄─▄ ▄─▄ ▄─▄ ▄ ▄─▄ ▄─▄                      █
  6.  █                     █ █ █─▄ ▀─▄ █─  ▀─▄ ▀─▄ ▄ █ █ █ █                      █
  7.  █                     █ █ █ █ ▄ █ █   ▄ █ ▄ █ █ █ █ █ █                      █
  8.  █                     ▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀ ▀ ▀▀▀ ▀ ▀ 1997                 █
  9.  █                                                                            █
  10.  █────────────────────────────────────────────────────────────────────────────█
  11.  █ Handle          Real name           Age   Profession   Group activity      █
  12.  █────────────────────────────────────────────────────────────────────────────█
  13.  █ Bugsy           Benjamin Petersen    23   Programmer   Coder, organizer(?) █
  14.  █ Spawn           Michael Skovslund    22   Programmer   Coder, gfx          █
  15.  █ UniSon          Henrik Eiriksson     23   Study IFA    Music, art          █
  16.  █────────────────────────────────────────────────────────────────────────────█
  17.  █   PLEASE CHECKOUT OUR INTERNET HOMEPAGE AT : WWW.CYBERNET.DK/USERS/BUGSY   █
  18.  █                                                                            █
  19.  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  20.  
  21. INDEX
  22.   History
  23.   Introduction
  24.   Disclaimer
  25.   Keyboard layout
  26.   Program documentation
  27.   Soft-Ice user notice           (New information, please take a look)
  28.   GameTools user notice          (New information, please take a look)
  29.   EatMem utility                 (New information, please take a look)
  30.   How to unpack an exefile
  31.   How to get in touch with us
  32.   Greetings                      (New information, please take a look)
  33.  
  34.  
  35. ■ History
  36.  
  37.   Version   Release Note
  38.  
  39.       1.0   Never released to the public, only for our beta-testers
  40.  
  41.       1.1   First public release
  42.  
  43.       1.2   Now with Soft-Ice debugger support. Activate with INT FCh
  44.  
  45.       2.0   Autodump from TD, S-ICE and GAMETOOLS. Detects a lot of things.
  46.             Uses UMB. Added Total Memory Dump feature, Show User Screen. Now it
  47.             swaps dos-stack so DUMPEXE can be activated at any time (reentrance)
  48.  
  49.       2.1   Fixed a bug in dos version check. (Damn)
  50.  
  51.       2.2   Added support for overlay as requested by José Navarro Martínez
  52.             Fixed minor bugs in DUMPEXE. Added mail registration form
  53.             Added a utility called EATMEM that allocates 4 KB from within DOS.
  54.             Removed the WORD version of this doc file (Did anybody use it ?).
  55.  
  56. ■ Introduction
  57.  
  58.   This program is able to unpack ANY exe-packed file. Many other programs,
  59.   such as cup, up, tron, unp and vgacbust give you the same ability. But those
  60.   programs can only expand/unpack files packed with known exepackers. By
  61.   using the OBSESSiON DUMPEXE toolpack, you can unpack any of those exe-files
  62.   that the above utilitys gave up on. Of course this can't be done by inserting
  63.   a quarter (kr.) into the crypt-o-mate. We have to do a little more than this.
  64.   This is where you, the OBSESSiON DUMPEXE toolpack, and your debugger gets
  65.   into the picture.
  66.  
  67.   All you have to do is this :
  68.     Load the exeprogram into your favourite debugger (eg. TD, S-ice, GameTools)
  69.     Debug the program until first original (unpacked) instruction
  70.     Dump the code/data, using the DUMPEXE program, via the FILE 1 option
  71.     Terminate the loaded program
  72.     Allocate a 4 Kb memory block via the DUMPEXE program (or use EATMEM.EXE)
  73.     Reload the program, and ensure that the entry point is different
  74.     Debug the program until first original (unpacked) instruction
  75.     Dump the code/data, using the DUMPEXE program, via the FILE 2 option
  76.     Terminate the loaded program
  77.     Deallocate the 4 Kb memory block via the DUMPEXE program (or use EATMEM.EXE)
  78.     Run MAKEEXE with the needed parameters.
  79.       Example : MAKEEXE.EXE ORIGINAL.EXE NEWFILE.EXE
  80.  
  81.     And 'puf', your done.
  82.  
  83.   To technically understand how this can be done, please refer to selection :
  84.   "How to unpack an exefile".
  85.  
  86.   If this sounds easy, exit your doc reader now, if not, keep on reading. 8-)
  87.  
  88. ■ Disclaimer
  89.  
  90.   This software has been tested and found to work properly. OBSESSiON have no
  91.   responsbility whatsoever for any damages caused by use, or misuse of this
  92.   software.
  93.  
  94.   IF YOU DISAGREE WITH ANY OF THOSE TERMS, PLEASE REMOVE THIS SOFTWARE NOW.
  95.  
  96.   If after a 24 hour test period, you still wish to continue using this
  97.   software, you NEED to send us a postcard with your name and address or
  98.   register at our homepage at HTTP://WWW.CYBERNET.DK/USERS/BUGSY. The reason is
  99.   that it's the ONLY way I can explain to my wife why I have invested MORE than
  100.   200 hours developing this software. This is the only way I can see that
  101.   someone really is using this software. If I don't receive anything by mail,
  102.   I won't update the program any more.
  103.  
  104.   This means :
  105.     IF NOT (ReceivedAnyPostCardOrEMail) THEN
  106.       HALT (Programmer)
  107.     ELSE
  108.       ReleaseNextVersion
  109.  
  110. ■ Keyboard layout
  111.  
  112.   Left shift + right shift : Activate the resident part of DUMPEXE
  113.   TAB                      : Jump to next menu block
  114.   Shift TAB                : Jump to previous menu block
  115.   Arrow up/down            : Next/previous menu selection/block
  116.   Arrow left/right         : Next/previous digit or menu block
  117.   ESC                      : Terminate DUMPEXE or return to previous state
  118.   Enter                    : Confirm selection/input
  119.  
  120. ■ Program documentation
  121.  
  122.   Install DUMPEXE into memory by starting the file DUMPEXE.EXE. The program
  123.   will now go resident (TSR) in memory. This means that it can be envoked at
  124.   any time and within any program (such as a debugger). If UMB is available,
  125.   the 'DOS stack' and 'Screen swap data' will be placed here. To activate
  126.   DUMPEXE, please press <LEFT SHIFT> and <RIGHT SHIFT> at the same time (also
  127.   called the hotkey). A menu like the one shown below, should appear. To return
  128.   to interrupted program, press <ESC>.
  129.  
  130.   NOTICE : In previous versions you couldn't start DUMPEXE by pressing the
  131.            hotkey within the dos command line (InDOS). This has now been
  132.            fixed by using the technique called 'DOS stack switching'.
  133.  
  134.                FIG 1. The main picture of DUMPEXE
  135.  
  136.   ┌────── DumpExe v2.2 CARDWARE 1997 by BUGSY/OBSESSiON ──[1]─┐
  137.   │          Dos, ≥80386, V86 mode, Turbo Debugger        [2] │
  138.   │───────── First file ────[3]─┬───────── Second file ───[4]─│
  139.   │ CS   : 0000                 │ CS   : 0000                 │
  140.   │ IP   : 0000                 │ IP   : 0000                 │
  141.   │ SS   : 0000                 │ SS   : 0000                 │
  142.   │ SP   : 0000                 │ SP   : 0000                 │
  143.   │ PSP  : 0000                 │ PSP  : 0000                 │
  144.   │ Size : 00000 (0)            │ Size : 00000 (0)            │
  145.   │ Name : #NoName#.1           │ Name : #NoName#.2           │
  146.   │─────────────────────────[5]─┼─────────────────────────[6]─│
  147.   │      Dump exe-code          │      Dump exe-code          │
  148.   │      Autodetect name        │      Autodetect name        │
  149.   │      Autodetect size        │      Autodetect size        │
  150.   │─────────────────────────[7]─┼─────────────────────────[8]─│
  151.   │      Raster Bar             │      User screen            │
  152.   │      Memory snapshot        │      Allocate 4Kb           │
  153.   │      Reset menu             │      Auto config file 2     │
  154.   │      Uninstall              │      Fill from debugger     │
  155.   │─────────────────────────────┴─ Free 99 kb, Slack 0 kb [9]─│
  156.   │                                                      [10] │
  157.   └───────────────── Hotkey : (U)ser screen ──────────────────┘
  158.  
  159.   Overview
  160.     [1] Copyright text.
  161.     [2] Information on the operating system and found debuggers.
  162.     [3] Data for first memory dump, set by the user.
  163.     [4] -"-  for second memory dump.
  164.     [5] Menu concerning first memory dump.
  165.     [6] -"-  for second memory dump.
  166.     [7] General purpose menu, concerning global use of DUMPEXE.
  167.     [8] Utility menu with functions, helps you get the job done faster.
  168.     [9] Information about the current memory status.
  169.    [10] Shows status messages from DUMPEXE and serves as an input prompt.
  170.  
  171.   Explenation
  172.     [1] Copyright text.
  173.           Tells who made this brilliant program.
  174.  
  175.     [2] Information on the operating system and found debuggers.
  176.           Shows if current session is a DOS, WINDOWS or OS/2 session.
  177.           Also shows which debuggers have been found active at the present
  178.           moment.
  179.  
  180.           Can show a mixture of the following text strings :
  181.             [8086, 80286, ≥80386],
  182.             [Real mode, V86 mode],
  183.             [Dos, Win Std, Win Enh, OS/2],
  184.             [No debugger, Turbo Debugger, Soft-Ice, GameTools]
  185.  
  186.           Example : Dos, ≥80386, Real mode, Soft-Ice, GameTools
  187.  
  188.           As you can see, it is possible to have more than one debugger loaded
  189.           at the same time. This can be usefull when combining Turbo Debugger
  190.           and GameTools.
  191.  
  192.     [3] Data for first memory dump, set by the user.
  193.           This subwindow is used to enter information about the program you
  194.           want to unpack. You have to fill out ALL fields to get a working
  195.           copy of the unpacked program.
  196.  
  197.             CS   : Current code segment
  198.             IP   : Current instruction pointer
  199.             SS   : Current stack segment
  200.             SP   : Current stack pointer
  201.             PSP  : Current program prefix segment, usually the same as ES
  202.             Size : Size of program in bytes
  203.             Name : Name of dump file
  204.  
  205.           To change a value, move the selector to the decided item and press
  206.           <ENTER>. Enter the new value and press <ENTER> again.
  207.           REMARK : All numbers are shown and entered in heximal values.
  208.                    The filename can not be entered manuelly.
  209.  
  210.     [4] -"- for second memory dump. ([3])
  211.  
  212.     [5] Menu concerning first memory dump.
  213.           It is used for dumping the code/data block entered in [3] or [4].
  214.  
  215.           Menu items available are :
  216.  
  217.             Dump exe-code   : Select this one to dump selected code/data block.
  218.  
  219.             Autodetect name : Let DUMPEXE autodetect the name of the program
  220.                               its processing, and use it as the dump filename.
  221.  
  222.             Autodetect size : Let DUMPEXE autodetect the size of the code/data
  223.                               block. There are two ways to autodetect this
  224.                               size. It can be done by Stack or by PSP. The
  225.                               most common way is 'By Stack', because this
  226.                               usually gives a smaller, and more acurrent image
  227.                               of the original unpacked exefile.
  228.  
  229.     [6] -"- for second memory dump. ([5])
  230.  
  231.     [7] General purpose menu, concerning the global use of DUMPEXE.
  232.  
  233.         Menu items available are :
  234.  
  235.             Raster Bar      : Switch between Raster Bar and Textmode Bar.
  236.                               It's a good idea to choose Textmode Bar if you
  237.                               are running under other systems than DOS such as
  238.                               Windows or OS/2.
  239.  
  240.             Memory snapshot : Takes a snapshot of the first megabyte of memory,
  241.                               and puts it in a file in the current directory,
  242.                               called SNAPSHOT.MEM. Use it for whatever you may
  243.                               like.
  244.  
  245.             Reset menu      : Sets all items to their initial value. Use it if
  246.                               something, somehow goes bananas.
  247.  
  248.             Uninstall       : Removes the DUMPEXE software from the memory.
  249.                               Use it if you want to remove the DUMPEXE from
  250.                               memory.
  251.  
  252.     [8] Utility menu with functions that helps you get the job done faster.
  253.  
  254.           Menu items available are :
  255.  
  256.             User screen        : Shows the screen as it was before DUMPEXE was
  257.                                  started. Use this function instead of pressing
  258.                                  <ESC> and then the hotkey. This function can
  259.                                  also be called by pressing <U> while in view
  260.                                  mode.
  261.  
  262.             (De)Allocate 4Kb   : Used to allocate/deallocate a block of 0100h
  263.                                  paragraphs (4 Kb). This should be done after
  264.                                  the first dump and termination, and before you
  265.                                  reload the program. Please take a look at the
  266.                                  tutorial later in this document. 
  267.  
  268.                                  NOTICE : This function can ONLY be used within
  269.                                           Turbo Debugger and GameTools. So if
  270.                                           you are using Soft-Ice, please use
  271.                                           the utility called EATMEM.EXE insted.
  272.  
  273.             Auto-Config        : Adds 0101h to all segment registers in [2] and
  274.                                  store them in [3]. It is useful after
  275.                                  preparing for second dump. This works only on
  276.                                  9 out 10 packed files. Please notice that CS
  277.                                  in [3] matches the one shown by the debugger.
  278.                                  If not, enter all values manually. You only
  279.                                  have to use this function if
  280.                                  "Fill from debugger" fails.
  281.  
  282.             Fill from debugger : Read the register shown by the debugger and
  283.                                  automatically place the values into first or
  284.                                  second dumpfile. This is a VERVY useful
  285.                                  function, since it gives you the ability to
  286.                                  unpack the exefile FAST.
  287.  
  288.     [9] Information about the current memory status.
  289.  
  290.           Free  : Amount of free basememory, in Kb.
  291.           Slack : Number of memory fragments in Kb, after allocating 4 Kb.
  292.  
  293.    [10] Status messages from DUMPEXE and input prompt.
  294.         This line serves as an error message and input scratch.
  295.  
  296.         Here are some of the error messages that can appear :
  297.  
  298.           No size given.
  299.             You have to enter how much memory the program needs to dump.
  300.  
  301.           No memory allocated.
  302.             You are trying to auto-config file 2, and you haven't used
  303.             "allocate 4KB". You must manually enter the data required to dump
  304.  
  305.           Can't auto-config file 2, sorry.
  306.             You have to manuelly, enter the data required to dump a program.
  307.             Or you could use the function : "Fill from debugger"
  308.  
  309.           The PSP-segment is not valid.
  310.             You are using a function that requires a valid PSP segment,
  311.             entered in [3] or [4].
  312.  
  313.           The PSP-segment for file 1 is not valid.
  314.             See the above.
  315.  
  316.           Can't find name.
  317.             DUMPEXE is not able to find the name of the program you want
  318.             to dump. The program is using a standard name instead.
  319.  
  320.           Can't uninstall, vector hooked by another program.
  321.             You have loaded another program after DUMPEXE. Unfortunately the
  322.             two programs have both hooked onto the same interrupt. Unload the
  323.             other program first and try again.
  324.  
  325.           Can't allocate necessary memory.
  326.             Boot your machine with fewer drivers, and try again. If this
  327.             does'nt help, you are f.....
  328.  
  329.           Out of stack.
  330.             Your memory is fragmented to much. The DUMPEXE has a 4 Kb stack and
  331.             in this case it doesn't seem to be enough. Contact us and ask for
  332.             a version with a larger stack, or modify the exeheader yourself. :)
  333.  
  334.           Can't release memory.
  335.             This error is most likely caused by the program you are about to
  336.             dump, or the stack of this program has been destroyed. Dump the
  337.             code and boot your PC. (the dumpfile should be okay, I hope...)
  338.  
  339.           Can't make file.
  340.             Oops, a disk error. Check your harddisk with "chkdsk /f" or
  341.             "scandisk"
  342.  
  343.           Can't write file, disk full ?.
  344.             Free some disk space, and try again.
  345.  
  346.           Can't deallocate memory.
  347.             The MCB (memory control block) has been destroyed. Dump the code
  348.             and boot your PC. (again, the dumpfile should be okay, I hope...)
  349.  
  350. ■ Soft-Ice user notice
  351.  
  352.   If you are using Soft-Ice, the hotkey is disabled. This is because Soft-Ice
  353.   runs in protected mode and uses its own interrupt vector table. To activate
  354.   DUMPEXE, enter the following sequence at the Soft-Ice command line prompt :
  355.  
  356.     BPX CS:IP      : So we can return after Int 0FCh has terminated
  357.     GENINT FC      : Start the exe-dumper
  358.     GENINT FC      : Start the exe-dumper again (if you need it)
  359.     BC 0           : Clear the breakpoint set by BPX. The number (in this case
  360.                      0) is the name of the breakpoint label.
  361.  
  362.   Don't start DUMPEXE unless you are are at the very first instruction of
  363.   the unpacked exefile because your current location might be in the keyboard
  364.   handler or equal.
  365.  
  366.   NOTICE : You cannot use the DUMPEXE menu called 'Allocate 4Kb' within
  367.            soft-ice. This function can ONLY be used within Turbo Debugger
  368.            and GameTools. Please use the utility called EATMEM.EXE insted.
  369.            (Look at selection 'EatMem utility' later)
  370.  
  371. ■ GameTools user notice
  372.  
  373.   If you are using GameTools, be SURE to load DUMPEXE BEFORE you load 
  374.   GameTools. If you don't, you can't activate DUMPEXE within GameTools.
  375.  
  376. ■ EatMem utility
  377.  
  378.   EatMem is a program that from within dos allows you to allocates
  379.   a 4 KB memory block.
  380.  
  381.   When you start EATMEM.EXE the first time it starts DUMPEXE (if resident) and
  382.   allocates a 4 KB memory block. The next time you start EATMEM.EXE it frees
  383.   the 4 KB memory block.
  384.  
  385.   Use this utility if you can't allocate a 4 KB memory block within DUMPEXE.
  386.   So insted of using the menu (in DUMPEXE) 'Allocate 4 KB', just return to dos,
  387.   and run EATMEM.EXE. When you are finished with the second dump, just run
  388.   EATMEM.EXE again, or release the 4 KB memory block via DUMPEXE.
  389.  
  390. ■ How to unpack an exefile
  391.  
  392.   The file named TESTEXE.EXE is a packed exe-file. It is used to illustrate
  393.   how to use this tool, and nothing more. The file is packed with pklite
  394.   version 2.01 using normal compression.
  395.  
  396.   I will use Turbo Debugger for this example, because if you know how to use
  397.   the ultimate debugger Soft-Ice, you probably don't need this introduction
  398.   anyway.
  399.  
  400.   If you don't know anything about using a debugger, I advise you to consult
  401.   your debuggers manual.
  402.  
  403.   Try to execute the tutorial program TESTEXE.EXE and take look at the text
  404.   it displays. The program will tell you if it's packed or not.
  405.  
  406.   REMEMBER : Start DUMPEXE.EXE before proceeding with the next step.
  407.  
  408.   Start debugging TESTEXE.EXE by writing : TD.EXE TESTEXE.EXE
  409.  
  410.   The picture shown, by TD (Turbo Debugger), should look something like
  411.   this :
  412.  
  413.   ╔═[■]═CPU 80486══════════════════════════════════╤═══════1═[][]═╗
  414.   ║  cs:010050             push   ax                ax 0000   │c=0║
  415.   ║  cs:0101 B82D06         mov    ax,062D         ■  bx 0000   │z=0║
  416.   ║  cs:0104 BA8201         mov    dx,0182         ▒  cx 0000   │s=0║
  417.   ║  cs:0107 050B63         add    ax,630B         ▒  dx 0000   │o=0║
  418.   ║  cs:010A 3B060200       cmp    ax,[0002]       ▒  si 0000   │p=0║
  419.   ║  cs:010E 722A           jb     013A            ▒  di 0000   │a=0║
  420.   ║  cs:0110 B409           mov    ah,09           ▒  bp 0000   │i=1║
  421.   ║  cs:0112 BA1C01         mov    dx,011C         ▒  sp 0200   │d=0║
  422.   ║  cs:0115 CD21           int    21              ▒  ds 62FB   │   ║
  423.   ║  cs:0117 B8014C         mov    ax,4C01         ▒  es 62FB   │   ║
  424.   ║  cs:011A CD21           int    21              ▒  ss 64B3   │   ║
  425.   ║  cs:011C 4E             dec    si              ▒  cs 62FB   │   ║
  426.   ║  cs:011D 6F             outsw                  ▒  ip 0100   │   ║
  427.   ║  cs:011E 7420           je     0140            ▒            │   ║
  428.   ║  cs:0120 656E           outsb  gs:                         │   ║
  429.   ╟■▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒┼────────────┴───╢
  430.   ║  ds:0000 CD 20 67 69 00 9A C0 00 ═ gi Ü└       │  ss:0208 0A76  ║
  431.   ║  ds:0008 00 00 E4 01 D3 29 AE 01   Σ╙)«      │  ss:0206 8BCB  ║
  432.   ║  ds:0010 D3 29 80 02 2E 24 9C 15 ╙)Ç.$£      │  ss:0204 8BF8  ║
  433.   ║  ds:0018 01 01 01 00 02 FF FF FF           │  ss:0202 8B0E  ║
  434.   ║  ds:0020 FF FF FF FF FF FF FF FF               │  ss:020074A6  ║
  435.   ╚════════════════════════════════════════════════╧═══════════════─┘
  436.   NOTICE : Due to the nature of the PC-memory, the segment registers
  437.            (CS, DS, ES, SS) might show different values than the one
  438.            shown.
  439.  
  440.   Start executing the code until cs:0153, by pressing <F4> at location cs:0153,
  441.   shown below. (Press <PAGEDOWN> 2 or 3 times)
  442.  
  443.   ╔═[■]═CPU 80486══════════════════════════════════╤═══════1═[][]═╗
  444.   ║  cs:0146 50             push   ax                ax 68FF   │c=0║
  445.   ║  cs:0147 B9C500         mov    cx,00C5         ■  bx 0000   │z=1║
  446.   ║  cs:014A 33FF           xor    di,di           ▒  cx 0000   │s=0║
  447.   ║  cs:014C 57             push   di              ▒  dx 0182   │o=0║
  448.   ║  cs:014D BE5401         mov    si,0154         ▒  si 02DE   │p=1║
  449.   ║  cs:0150 FC             cld                    ▒  di 018A   │a=0║
  450.   ║  cs:0151 F3A5           rep movsw              ▒  bp 0000   │i=1║
  451.   ║  cs:0153CB             retf                   ▒  sp 01FA   │d=0║
  452.   ║  cs:0154 FD             std                    ▒  ds 62FB   │   ║
  453.   ║  cs:0155 8CDB           mov    bx,ds           ▒  es 68FF   │   ║
  454.   ║  cs:0157 53             push   bx              ▒  ss 6918   │   ║
  455.   ║  cs:0158 83C32E         add    bx,002E         ▒  cs 62FB   │   ║
  456.   ║  cs:015B 90             nop                    ▒  ip 0153   │   ║
  457.   ║  cs:015C 03DA           add    bx,dx           ▒            │   ║
  458.   ║  cs:015E 8CCD           mov    bp,cs                       │   ║
  459.   ╟■▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒┼────────────┴───╢
  460.   ║  ds:0000 CD 20 67 69 00 9A C0 00 ═ gi Ü└       │  ss:0202 0005  ║
  461.   ║  ds:0008 00 00 E4 01 D3 29 AE 01   Σ╙)«      │  ss:0200 73A0  ║
  462.   ║  ds:0010 D3 29 80 02 2E 24 9C 15 ╙)Ç.$£      │  ss:01FE 0000  ║
  463.   ║  ds:0018 01 01 01 00 02 FF FF FF           │  ss:01FC 68FF  ║
  464.   ║  ds:0020 FF FF FF FF FF FF FF FF               │  ss:01FA0000  ║
  465.   ╚════════════════════════════════════════════════╧═══════════════─┘
  466.  
  467.   The unpacker has copied itself to a location, which is just after the
  468.   (not yet) unpacked code location. Singlestep one instruction (<F7>), and
  469.   you'll hopefully see this :
  470.  
  471.   ╔═[■]═CPU 80486══════════════════════════════════╤═══════1═[][]═╗
  472.   ║  cs:0000FD             std                      ax 68FF   │c=0║
  473.   ║  cs:0001 8CDB           mov    bx,ds           ■  bx 0000   │z=1║
  474.   ║  cs:0003 53             push   bx              ▒  cx 0000   │s=0║
  475.   ║  cs:0004 83C32E         add    bx,002E         ▒  dx 0182   │o=0║
  476.   ║  cs:0007 90             nop                    ▒  si 02DE   │p=1║
  477.   ║  cs:0008 03DA           add    bx,dx           ▒  di 018A   │a=0║
  478.   ║  cs:000A 8CCD           mov    bp,cs           ▒  bp 0000   │i=1║
  479.   ║  cs:000C 8BC2           mov    ax,dx           ▒  sp 01FE   │d=0║
  480.   ║  cs:000E 80E40F         and    ah,0F           ▒  ds 62FB   │   ║
  481.   ║  cs:0011 B104           mov    cl,04           ▒  es 68FF   │   ║
  482.   ║  cs:0013 8BF2           mov    si,dx           ▒  ss 6918   │   ║
  483.   ║  cs:0015 D3E6           shl    si,cl           ▒  cs 68FF   │   ║
  484.   ║  cs:0017 8BCE           mov    cx,si           ▒  ip 0000   │   ║
  485.   ║  cs:0019 D1E9           shr    cx,1            ▒            │   ║
  486.   ║  cs:001B 4E             dec    si                          │   ║
  487.   ╟■▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒┼────────────┴───╢
  488.   ║  ds:0000 CD 20 67 69 00 9A C0 00 ═ gi Ü└       │  ss:0206 0000  ║
  489.   ║  ds:0008 00 00 E4 01 D3 29 AE 01   Σ╙)«      │  ss:0204 0000  ║
  490.   ║  ds:0010 D3 29 80 02 2E 24 9C 15 ╙)Ç.$£      │  ss:0202 0005  ║
  491.   ║  ds:0018 01 01 01 00 02 FF FF FF           │  ss:0200 73A0  ║
  492.   ║  ds:0020 FF FF FF FF FF FF FF FF               │  ss:01FE0000  ║
  493.   ╚════════════════════════════════════════════════╧═══════════════─┘
  494.  
  495.   Press <F4> at location cs:0161 (the retf instruction), found by pressing
  496.   <PageDown> 13 - 14 times; and then <F7>. That's it. You have now unpacked
  497.   the TESTEXE program. If you have done it right, TD shows something like this :
  498.  
  499.   ╔═[■]═CPU 80486══════════════════════════════════╤═══════1═[][]═╗
  500.   ║  cs:010F9A00001464     call   6414:0000         ax 0000   │c=0║
  501.   ║  cs:0114 9A0D00B263     call   63B2:000D       ■  bx 0000   │z=1║
  502.   ║  cs:0119 9A60073A63     call   633A:0760       ▒  cx 0000   │s=0║
  503.   ║  cs:011E 55             push   bp              ▒  dx 0000   │o=0║
  504.   ║  cs:011F 89E5           mov    bp,sp           ▒  si 0000   │p=1║
  505.   ║  cs:0121 B80001         mov    ax,0100         ▒  di 0000   │a=0║
  506.   ║  cs:0124 9ACD021464     call   6414:02CD       ▒  bp 0000   │i=1║
  507.   ║  cs:0129 81EC0001       sub    sp,0100         ▒  sp 4000   │d=0║
  508.   ║  cs:012D 9ACC01B263     call   63B2:01CC       ▒  ds 62FB   │   ║
  509.   ║  cs:0132 BFB400         mov    di,00B4         ▒  es 62FB   │   ║
  510.   ║  cs:0135 1E             push   ds              ▒  ss 6548   │   ║
  511.   ║  cs:0136 57             push   di              ▒  cs 630B   │   ║
  512.   ║  cs:0137 8DBE00FF       lea    di,[bp-0100]    ▒  ip 010F   │   ║
  513.   ║  cs:013B 16             push   ss              ▒            │   ║
  514.   ║  cs:013C 57             push   di                          │   ║
  515.   ╟■▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒┼────────────┴───╢
  516.   ║  ds:0000 CD 20 67 69 00 9A C0 00 ═ gi Ü└       │  ss:4008 0000  ║
  517.   ║  ds:0008 00 00 E4 01 D3 29 AE 01   Σ╙)«      │  ss:4006 0000  ║
  518.   ║  ds:0010 D3 29 80 02 2E 24 9C 15 ╙)Ç.$£      │  ss:4004 0000  ║
  519.   ║  ds:0018 01 01 01 00 02 FF FF FF           │  ss:4002 0005  ║
  520.   ║  ds:0020 FF FF FF FF FF FF FF FF               │  ss:400074A0  ║
  521.   ╚════════════════════════════════════════════════╧═══════════════─┘
  522.  
  523.   As you can see there are three far calls. These are direct calls. This means
  524.   that it will make a call to a certain location in memory. If we dump the
  525.   memory used by TESTEXEE, we'll have an image of the program. But this is not
  526.   enough to make a new exefile. This is because an exefile is not just an image
  527.   of the memory, like a COM file is. We need a second dump from a different
  528.   memory location. This is because of the direct calls. By comparing the two
  529.   dumps, we can find the relocations (direct calls) needed to build a new
  530.   exefile. Information like min/max memory usage is taken from the original
  531.   exefiles header, but let's get on with the tutorial.
  532.  
  533.   There are serval ways to enter the values of SP, DS, ES, SS, CS and IP into
  534.   DUMPEXE. Since we are using one of the supported debuggers, we can use
  535.   the "Fill from debugger" function. This function takes register values, shown
  536.   by the debugger, and automatically puts them into DUMPEXE. Start DUMPEXE
  537.   by pressing the hotkey, and then <ENTER> at the "Fill from debugger"
  538.   function. Answer <1> to whatever the values should be places in first or
  539.   second dump file. Another way is to remember the values of SP, DS, ES, SS,
  540.   CS and IP before pressing the hotkey, and enter the values at their
  541.   corresponding locations in [2]. If you decide to do so, you will probably
  542.   notice that there is no field for ES. This is because the initial value of
  543.   ES, points to the PSP, so write the value of ES in the PSP field instead.
  544.  
  545.   It's now time to tell DUMPEXE the size of the memory block we want to dump.
  546.   Use TAB until you get to [4]. Press <ENTER> at "Autodetect size". There are
  547.   two ways of getting the size of the program. One is by using the stack, the
  548.   other is by using PSP. 99 % of all cases, you should use "by stack". Press
  549.   <S>, and the size will be put into size field. If DUMPEXE somehow fails to
  550.   calculate the right value, you have the option of entering a size that you
  551.   decide. Press <ENTER> at "Autodetect name", and the name of the executeable
  552.   file will be put into the name field. The last thing we have to do is to
  553.   dump the program to a file. This is done by pressing <ENTER> at
  554.   "Dump exe-code". DUMPEXE will probably do it so fast that you won't notice
  555.   the "process message" that appears.
  556.  
  557.   Below is a picture of DUMPEXE after the first dump. Again, remember that
  558.   values varie from dump to dump.
  559.  
  560.   ┌────── DumpExe v2.2 CARDWARE 1997 by BUGSY/OBSESSiON ──────┐
  561.   │          Dos, ≥80386, V86 mode, Turbo Debugger            │
  562.   │───────── First file ────────┬───────── Second file ───────│
  563.   │ CS   : 630B                 │ CS   : 0000                 │
  564.   │ IP   : 010F                 │ IP   : 0000                 │
  565.   │ SS   : 6548                 │ SS   : 0000                 │
  566.   │ SP   : 4000                 │ SP   : 0000                 │
  567.   │ PSP  : 62FB                 │ PSP  : 0000                 │
  568.   │ Size : 023D0 (9168)         │ Size : 00000 (0)            │
  569.   │ Name : TESTEXE.1            │ Name : #NoName#.2           │
  570.   │─────────────────────────────┼─────────────────────────────│
  571.   │      Dump exe-code          │      Dump exe-code          │
  572.   │      Autodetect name        │      Autodetect name        │
  573.   │      Autodetect size        │      Autodetect size        │
  574.   │─────────────────────────────┼─────────────────────────────│
  575.   │      Raster Bar             │      User screen            │
  576.   │      Memory snapshot        │      Allocate 4Kb           │
  577.   │      Reset menu             │      Auto config file 2     │
  578.   │      Uninstall              │      Fill from debugger     │
  579.   │─────────────────────────────┴─ Free 218 kb, Slack 0 kb ───│
  580.   │                                                           │
  581.   └───────────────── Hotkey : (U)ser screen───────────────────┘
  582.  
  583.   Press <ESC> (in DUMPEXE) and then <F9> in TD. The program has now terminated,
  584.   and it's time to allocate a 4KB memory block.
  585.  
  586.   Start DUMPEXE again, and press enter at "Allocate 4Kb". The menu item will
  587.   change to "Deallocate 4Kb". Press <ESC>, and reload the program by pressing
  588.   <CTRL F2>. Start debugging like you did the first time. When you have reached
  589.   the first instruction of the original code, enter all the information, like CS,
  590.   SS.... in [3]. Autodetect size and name. Dump the code, and we are almost
  591.   done. Again terminate your program, by pressing <F9> in TD. Start DUMPEXE
  592.   again, and press <ENTER> at 'Deallocate 4Kb'. Exit your debugger.
  593.  
  594.   Run the MAKEEXE program with parameters : TESTEXE.EXE UNPACKED.EXE
  595.  
  596.   or like this : MAKEEXE.EXE TEXTEXE.EXE UNPACKED.EXE
  597.  
  598.   The MAKEEXE program compares the two memory dump and builds a new exefile
  599.   out of the information found there and in the original exefiles header.
  600.  
  601.   After MAKEEXE has built the new exefile, the screen should look like this :
  602.  
  603.   ┌─────────────────────────────────────────────────────────┐
  604.   │ ─┼── MakeExe v2.2 CARDWARE 1997 by BUGSY/OBSESSiON ─┼── │
  605.   │                                                         │
  606.   │                                                         │
  607.   │Unpacking TESTEXE.EXE into UNPACKED.EXE                  │
  608.   │                                                         │
  609.   │■ Read dump info                                         │
  610.   │■ Read exe info                                          │
  611.   │■ Create new file                                        │
  612.   │■ Create tempfile                                        │
  613.   │■ Write relocations                                      │
  614.   │■ Write zero data                                        │
  615.   │■ Write code                                             │
  616.   │■ Write new header                                       │
  617.   │■ Number of relocations 00BEh                            │
  618.   │                                                         │
  619.   │All done!                                                │
  620.   │                                                         │
  621.   └─────────────────────────────────────────────────────────┘
  622.  
  623.   Try to execute UNPACKED.EXE (it is now unpacked) and see how it reacts.
  624.  
  625.   I think this would be enough for you to continue on your own.
  626.  
  627. ■ How to get in touch with us
  628.  
  629.   If you have any questions about the use of these programs, feel free to
  630.   contact us.
  631.  
  632.   You can get in touch with us by :
  633.  
  634.   Writing a letter to    : Benjamin Petersen
  635.               Joergen Jensensvej 16B
  636.               DK-4700 Naestved
  637.               Denmark
  638.  
  639.                           After 1997-04-15 (Y-M-D) :
  640.  
  641.                           Benjamin Petersen
  642.                           Skovburren 271
  643.                           4700 Naestved
  644.                           Denmark
  645.  
  646.   E-Mail us at        : bugsy@cybernet.dk
  647.  
  648.   World Wide Web (WWW)    : http://www.cybernet.dk/users/bugsy/default.htm
  649.  
  650.   Call us at        : +45 53 725-610 or +45 40 204-347
  651.  
  652. ■ Greetings
  653.  
  654.   Our greetings goes to (no order) :
  655.  
  656.   Darkman/VLAD, Ping (pingelingelater), HiTech, Bionic, Jazz/PM,
  657.   --=DaRk sTAlKeR 97=--, JauMing Tseng, Kevin Tseng, Philippe Ahles,
  658.   Hades Wu, Jean-Stephane PERRI, Michael Pedersen, tHEpHARAo^mSH
  659.   Daniel Fazekas, Jung-ho Ryu, Mariusz Kowalczyk aka -KoVi-,
  660.   José Navarro Martínez, TBD/FeR, LiBaTiOn, MaNaGeR
  661.  
  662. Have fun, and remember there are still some people who DON'T take money
  663. for making ?good? programs.
  664.  
  665. [BUGSY/OBSESSiON]